<template>
  <div>
    <van-tabs v-model="active" sticky animated>
      <van-tab v-for="item in lk001" :key="item.id" :title="item.name" >
            <div class="box" v-for="i in item.products" :key="i.id" >
                <div class="imgBox">
                    <img @click="tiaoz(i)" v-lazy="i.small_image" alt="">
                </div>
                <div class="rightBox">
                    <div class="nameBox">{{i.name}}</div>
                    <div class="spec">{{i.spec}}</div>
                    <div class="priceBox">
                        <span>{{i.price}}</span>
                        <span>{{i.price}}</span>
                    </div>
                    <div @click="addGw(i)" class="icon-gw"></div>
                </div>
            </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
export default {
  name: "MainView",
  props:["lk001"],
  data() {
    return {
        active: 0,
    }
  },
  methods:{
    addGw(item){
        if(localStorage.getItem("token")){
            this.$store.commit("storage",item)
        }else{
            this.$router.push("/login")
        }
        
        console.log(item);
    },
    
  }
};
</script>

<style lang="scss" scoped>
.van-tab__pane-wrapper{
    height: 80vh;
    overflow: auto;
}
.box{
    width: 70%;
    display: flex;
    position: relative;
    margin-bottom: .3rem;
}
.imgBox{
    img{
        width: 1.8rem;
        height: 1.8rem;
    }
}
.rightBox{
    width: 100%;
    .nameBox{
        width: 100%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        margin-top: .1rem;
        font-size: .34rem;
    }
    .spec{
        width: 100%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        margin-top: .1rem;
        font-size: .26rem;
        color: #9FA4A9;
    }
    .priceBox{
        margin-top: .2rem;
        font-size: .34rem;
        span:nth-child(1){
            color: red;
        }
        span:nth-child(2){
            color: #9FA4A9;
            text-decoration: line-through;
            margin-left: .2rem;
            font-size: .28rem;
        }
    }
}
.icon-gw{
    width: .7rem;
    height: .7rem;
    background: url("../../../../ps原图/assets/img/icon/2.png") no-repeat;
    background-size: 100% 100%;
    position: absolute;
    right: -1.5rem;
    bottom: 0;
}
</style>